package com.yanqu.road.server.cmd.activity.hanghai.cross;

import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.pb.activity.HangHaiActivityProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

@Cmd(code = GameProtocol.S_HANGHAI_ACTIVITY_GET_REPORT_REWARD_FROM_CROSS, desc = "（跨服返回）返回领取上报奖励")
public class HangHaiGetReportRewardFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        HangHaiActivityProto.GetHangHaiReportRewardRespMsg respMsg = HangHaiActivityProto.GetHangHaiReportRewardRespMsg.parseFrom(packet.getBytes());

        if (respMsg.getRet() == 0) {
            Property property = PropertyHelper.parseStringToProperty(respMsg.getReward());
            player.getModule(CurrencyModule.class).addCurrency(property, eLogMoneyType.HangHaiActivity, eLogMoneyType.HangHaiGetReportReward);
        }

        player.sendPacket(ClientProtocol.U_HANGHAI_ACTIVITY_GET_REPORT_REWARD, respMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
